<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <include file="Public:resource"/>
    <title>账号绑定</title>
</head>
<body>
<div class="container">
    <include file="Public:top" title="账号绑定"/>

    <div class="row" align="left" style="margin-top: 10px;">
        <div class="col-xs-3 col-md-3 col-sm-3 col-lg-3 align-to-input medium">
            水费账号
        </div>
        <div class="col-xs-9 col-md-9 col-sm-9 col-lg-9">
            <input type="text" value="" id="account" placeholder="请输入水费账号">
        </div>
    </div>
    <div class="row" align="left" style="margin-top: 10px;">
        <div class="col-xs-3 col-md-3 col-sm-3 col-lg-3 align-to-input medium">
            姓名
        </div>
        <div class="col-xs-9 col-md-9 col-sm-9 col-lg-9">
            <input type="text" value="" id="name" placeholder="请输入姓名">
        </div>
    </div>
    <div class="row" align="left" style="margin-top: 10px;">
        <div class="col-xs-3 col-md-3 col-sm-3 col-lg-3 align-to-input medium">
            证件号
        </div>
        <div class="col-xs-9 col-md-9 col-sm-9 col-lg-9">
            <input type="text" value="" id="id-number" placeholder="请输入证件号">
        </div>
    </div>

    <div class="row" style="margin-top: 20px;">
        <div class="col-xs-12 col-sm-12 col-mg-12 col-md-12">
            <div><input type="button" class="btn btn-lg btn-block jss-button"
                        onclick="onSubmit()" value="确定"/>
            </div>
        </div>
    </div>
</div>
<include file="Public:progress" hint="绑定中..."/>
<include file="Public:message"/>
<script>
    function onSubmit() {
        if (!checkBindInfo()) {
            return;
        }
        showProgress();
        var param = {
            name: $("#name").val(),
            account: $("#account").val(),
            number: $("#id-number").val()
        }
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: "{:U('Bind/bind')}",
            data: param,
            async :false,
            contentType: 'application/x-www-form-urlencoded;charset=utf-8',
            success: function (json) {
                hideProgress();
                if (json.status == 'success') {
                    showMessage(json.msg, 1000);
                    setTimeout(function () {
                        window.location.href = "{:U('index')}";
                    }, 1000);
                } else {
                    alert(json.msg);
                }
            },
            error: function (msg) {
                alert("绑定失败,请检查网络!");
            }
        });

    }
    //检查输入
    function checkBindInfo() {

        if ($("#account").val() == '') {
            alert("请填写正确的账号");
            return false;
        }

        if ($("#name").val() == '') {
            alert("请填写正确的姓名");
            return false;
        }
		/*
        if (!isIdCardNo($("#id-number").val())) {
            alert("请填写正确的证件号!");
            return false;
        } */

		if($("#id-number").val() == ''){
			alert("请填写正确的证件号!");
			return false;
		}
        return true;
    }
</script>
</body>
</html>